﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using XDAFacebook;
using XFControls.Utils;

namespace FBEntities.FBObjects
{
    public class FBNote : IFBObject
    {
        public FBComments comments;
        public DateTime created_time;
        public FBFrom from;
        public string icon;
        public string id;
        public string message;
        public string subject;
        public DateTime updated_time;

        #region IFBObject Members

        public void Parse(JObject text)
        {
            FBParseUtilities.Parse(text, this);
        }

        #endregion

        public FBPost ToPost()
        {
            var ret = new FBPost
                      {
                          id = id,
                          from = from,
                          name = subject,
                          description = message,
                          icon = icon,
                          created_time = created_time,
                          updated_time = updated_time,
                          comments = comments,
                          type = "inbox"
                      };

            return ret;
        }

        public WebDownloaderWrapper Create()
        {
            string authKeyCode = FBParseUtilities.authKeySplit;
            var args = new Dictionary<string, string>();
            args.Add("access_token", authKeyCode);
            args.Add("subject", subject);
            args.Add("message", message);

            var ret = new WebDownloaderWrapper("https://graph." + Settings.Domain + ".com/me/notes") { PostData = args };

            return ret;
        }
    }
}